package com.tepth.busfix.adapter;

import android.content.Context;
import android.support.graphics.drawable.VectorDrawableCompat;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.tepth.busfix.R;
import com.tepth.busfix.bean.reponse.AlarmInfo;

import java.util.List;

/**
 * Created by 张宇 on 2017/3/15.
 */

public class AlarmListAdapter extends BaseQuickAdapter<AlarmInfo, BaseViewHolder> {
    private Context mContext;

    public AlarmListAdapter(Context context, int layoutResId, List<AlarmInfo> data) {
        super(layoutResId, data);
        mContext = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, AlarmInfo item) {
        VectorDrawableCompat drawable = null;
        switch ((int) item.getLevel()) {
            case 1:
                drawable = VectorDrawableCompat.create(mContext.getResources(),R.drawable.ic_warning_level_3_24dp,mContext.getTheme());
                break;
            case 2:
                drawable = VectorDrawableCompat.create(mContext.getResources(),R.drawable.ic_warning_level_2_24dp,mContext.getTheme());
                break;
            case 3:
                drawable = VectorDrawableCompat.create(mContext.getResources(),R.drawable.ic_warning_level_1_24dp,mContext.getTheme());
                break;
        }

        helper.setImageDrawable(R.id.iv_alarm, drawable);
        helper.setText(R.id.tv_alarm_name, item.getName());
        helper.setText(R.id.tv_alarm_time, "开始时间:" + item.getStartTimeStr()
                + " 结束时间:" + item.getEndTimeStr());
        helper.setText(R.id.tv_alarm_des, item.getMsg());
    }

}
